/*
ID: guoxu1
PROG: sort3
LANG: C++
*/
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

#define cin fin
#define cout fout

int iabs( int k )
{
  return k < 0 ? -k : k;
}

int main()
{
  ifstream fin( "sort3.in" );
  ofstream fout( "sort3.out" );
  
  int n = 0;
  cin >> n;
  vector<int> s1(n);
  for( int i = 0; i < n; i++ )
  {
    cin >> s1[i];
  }
  vector<int> s2 = s1;
  std::sort( s2.begin(), s2.end() );

  int F[6] = {0};
  int sum = 0;
  for( size_t i = 0; i < s1.size(); i++ )
  {
    if( s1[i] == s2[i] ) continue;
    int& p = F[s1[i] + s2[i]];
    int k = s1[i] < s2[i] ? -1 : 1;
    if( p > 0 && k < 0 || p < 0 && k > 0 )
    {
      sum++;
    }
    p += k;
  }
//  if( abs(F[3]) != abs(F[4]) || abs(F[4]) != abs(F[5]) || abs(F[5]) != abs(F[3]) )
//  {
//    cout << "error!" << endl;
//    cout << F[3] << " " << F[4] << " " << F[5] << endl;
//  }
//  
  cout << sum + iabs(F[3]) * 2 << endl;

  
  return 0;
}
